import type { RouteLocationRaw } from "vue-router";
import { router as globalRouter } from "@/router";

export const routerPush = (to: RouteLocationRaw, newTab = false) => {
  const router = useRouter() || globalRouter;
  if (newTab) {
    const routerData = router.resolve(to);
    window.open(routerData.href, "_blank");
    return Promise.resolve();
  }
  return router.push(to);
};
